#!/usr/bin/python
"""
Navala Console

Code based on [1]

The console is currently working in client mode (the NavalaSystem has
flagMaster=False). This causes all verbose feedback to be shown at the
navala.py window.

References
[1] http://ipython.org/ipython-doc/rel-0.13.2/interactive/reference.html#embedding

"""

'''
Not used
def namespace():
    import system.navalasystem as na
    na.vala.flagMaster = False
    na.vala.Startup() # Starts a new System
    from system import consolefunctions as nc
    return locals()
'''

_code = """
import system.navalasystem as na
na.vala.flagMaster = True
na.vala.flagStartRTM = False
na.vala.Startup() # Starts a new System
import datetime as dt
import numpy as np
from system.consolefunctions import *
from misc import quoteperiod as qp
from misc import misc
from misc import timedata
from analysis import maths
"""


    
#print namespace()
#a = raw_input(" asdadsdsa ")

# First import the embeddable shell class
from IPython.frontend.terminal.embed import InteractiveShellEmbed

# Now create an instance of the embeddable shell. The first argument is a
# string with options exactly as you would type them if you were starting
# IPython at the system command line. Any parameters you want to define for
# configuration can thus be specified here.
ipshell = InteractiveShellEmbed(
                       banner1 = """
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Navala Console^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Navala-Powered IPython
Starts a master NavalaSystem as na.vala
and imports a few more modules.
\n
^^^^^Startup code:^^^^^\n"""+_code+
"""
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


        ^^O^^-

                       ^o^-\n
""",
                       exit_msg = 'Leaving Navala Console.')
#ipshell.run_code(_code)
#ipshell.user_global_ns = namespace()
exec _code in globals()
ipshell()
